//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CEffectPool9.cpp>
///	@path	~/src/graphics/dx9/
///	@date	2007/11/21
///	@desc	Effect pool implementation in DX9.

#include "config/config.h"

#include "graphics/dx9/CEffectPool9.h"
#include "graphics/dx9/CEffect9.h"

namespace xeres {

	IMPL_IOBJECT_CLASS( CEffectPool9 );

	// ctor
	CEffectPool9::CEffectPool9( ID3DXEffect * master , ID3DXEffectPool * pool )
		: m_pEffectPool( pool )
	{
		m_effect = new CEffect9( master , NULL );
	}

	// dtor
	CEffectPool9::~CEffectPool9( void )
	{
		m_effect = NULL;
		if( m_pEffectPool )
		{
			UINT rest = m_pEffectPool->Release();
			if( rest != 0 )
			{
				TRACE_ERROR( _S("CEffectPool9::DTOR: Invalid ID3DXEffectPool reference count.") );
				FATAL_ABORT( _S("Invalid ID3DXEffectPool reference count.") );
			}
		}
	}

	// GetEffectPoolInterface
	IUnknown * CEffectPool9::GetEffectPoolInterface( void )
	{
		return m_pEffectPool;
	}

	RefPass<IEffect> CEffectPool9::GetMasterEffect( void )
	{
		return m_effect;
	}

} // namespace xeres
